ROOT=..
BUILD_DIR= ./build

CXXFLAGS= -g -I./utils -I $(ROOT)/common/include -I $(ROOT)/xstub_dahua -I . 
LDFLAGS= -L $(ROOT)/common/lib
LIBS=-lsvcommon -lresolv $(ROOT)/common/lib/libcl.a -ldhdvr -ldhnetsdk -ldhparser 

SUBDIRS=utils
CPP_FILES=$(wildcard *.cpp)
HPP_FILES=$(wildcard *.hpp)
OBJ_FILES=$(patsubst %.cpp,%.o,$(CPP_FILES))


.PHONY: all clean submake
all: init demo

init:
	mkdir -p ./build
#	@echo $(ALL_CPP)

$(OBJ_FILES):$(CPP_FILES) $(HPP_FILES)
	$(CXX) -c $(CXXFLAGS) $< -o $(BUILD_DIR)/$@

submake:$(SUBDIRS)
	make -C $<
	
demo: submake $(OBJ_FILES) 
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBS) -o  $@ $(BUILD_DIR)/*.o
 

clean:
	rm -rf demo ut_sel

ut_sel:
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBS) -o $@ unit_test/test_selector.cpp selector.cpp
